<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/weadmin.css">
    <script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/lib/jquery-2.1.3.min.js"></script>
</head>
<body>
<div style="margin: 10px">
    <button onclick="showPWD()" class="layui-btn layui-btn-lg layui-btn-normal">修改密码</button>
    <button onclick="showSNO()" id="changeSNO" class="layui-btn layui-btn-lg layui-btn-normal">修改安全码</button>
</div>
<div id="changePassword" style="display: none">
    <p>账号</p>
    <input id="AC_PWD" name="account"  type="text" lay-verify="required" class="layui-input" >
    <hr class="hr15">
    <p>安全码</p>
    <input id="SNO" name="securityno"  type="text" lay-verify="required" class="layui-input" >
    <hr class="hr15">
    <p>密码</p>
    <input id="PWD" name="password" lay-verify="required" type="password" class="layui-input">
    <hr class="hr15">
    <button onclick="changePWD()" class="layui-btn layui-btn-lg layui-btn-normal">确定</button>
    <button onclick="back()" class="layui-btn layui-btn-lg layui-btn-normal">返回</button>
</div>
<div id="changeSecurityNo" style="display: none">
    <p>账号</p>
    <input id="AC_SNO" name="account"  type="text" lay-verify="required" class="layui-input" >
    <hr class="hr15">
    <p>旧安全码</p>
    <input id="SNO_OLD" name="securityno_old"  type="text" lay-verify="required" class="layui-input" >
    <hr class="hr15">
    <p>新安全码</p>
    <input id="SNO_NEW" name="password_new" lay-verify="required" type="text" class="layui-input">
    <hr class="hr15">
    <button onclick="changeSNO()" class="layui-btn layui-btn-lg layui-btn-normal">确定</button>
    <button onclick="back()" class="layui-btn layui-btn-lg layui-btn-normal">返回</button>
</div>
<script type="text/javascript">

    function showPWD() {
        layui.use('layer', function(){
            var layer = layui.layer;

            layer.open({
                type: 1,
                content: $('#changePassword')
            });
        });
    }
    function showSNO() {
        layui.use('layer', function(){
            var layer = layui.layer;

            layer.open({
                type: 1,
                content: $('#changeSecurityNo')
            })
        });
    }
    function back() {
        layui.use('layer', function(){
            var layer = layui.layer;

            layer.closeAll();
        });
    }
    function changePWD() {
        var account = $("#AC_PWD").val();
        var securityno = $("#SNO").val();
        var password = $("#PWD").val();
        $.ajax({
            type : "POST",
            url : "/admin/changepwd",
            data : {
                "account" : account,
                "securityno" : securityno,
                "password" : password
            },
            async : false,
            cache : false,
            success : function(data) {
                if (JSON.parse(data).msg == "success") {
                    alert("修改密码成功");
                    layui.use('layer', function(){
                        var layer = layui.layer;

                        layer.closeAll();
                    });
                }else {
                    alert("修改密码失败");
                }
            },
            error : function() {
                alert("系统错误");
            }
        });
    }
    function changeSNO() {
        var account = $("#AC_SNO").val();
        var securityno_old = $("#SNO_OLD").val();
        var securityno_new = $("#SNO_NEW").val();
        $.ajax({
            type : "POST",
            url : "/admin/changesecno",
            data : {
                "account" : account,
                "securityno_old" : securityno_old,
                "securityno_new" : securityno_new
            },
            async : false,
            cache : false,
            success : function(data) {
                if (JSON.parse(data).msg == "success") {
                    alert("修改安全码成功");
                    layui.use('layer', function(){
                        var layer = layui.layer;

                        layer.closeAll();
                    });
                }else {
                    alert("修改安全码失败");
                }
            },
            error : function() {
                alert("系统错误");
            }
        });
    }
</script>
</body>
</html>